<template>
  <van-cell
    class="article-item"
    :to="{
      name: `article`,
      params: {
        artID: article.art_id,
      },
    }"
  >
    <!-- @click="
      $router.push({
        name: 'article',
        params: {
          artID: article.art_id,
        },
      })" -->
    <!-- @click="$router.push(`/article/${article.art_id}`)" -->

    <!-- :to="{
      path: `/article/${article.art_id}`,
    }" -->
    <!-- name: 'article',
      params: { artID: article.art_id },
      query: {
        a: 1,
      }, -->
    <!-- @click="$router.push(`/article/${article.art_id}`)" -->
    <!-- name: 'article',
      params: { artID: article.art_id } -->
    <!-- :to="{
      name: 'article',
      params: { artID: article.art_id },
    }" -->
    <template v-slot:title>
      <div class="title">
        {{ article.title }}
      </div>
    </template>
    <template v-slot:label>
      <div class="label">
        <div class="label-cover-wrap" v-if="article.cover.type === 3">
          <van-image
            fit="cover"
            class="label-cover-item"
            v-for="(img, index) in article.cover.images"
            :key="index"
            :src="img"
          />
        </div>
        <div class="label-info-wrap">
          <span>{{ article.aut_name }}</span>
          <span>{{ article.comm_count }}评论</span>
          <span>{{ article.pubdate | dateFormat }}</span>
        </div>
      </div>
    </template>
    <template v-slot:default v-if="article.cover.type === 1">
      <van-image
        fit="cover"
        class="right-cover"
        :src="article.cover.images[0]"
      />
    </template>
  </van-cell>
</template>

<script>
export default {
  name: 'ArticleItem',
  data () {
    return {}
  },
  props: {
    article: {
      type: Object,
      required: true
    }
  }
}
</script>

<style lang="less" scoped>
.article-item {
  align-items: center;
  .title {
    font-size: 32px;
    color: #3a3a3a;
    //记得一定要给div宽度
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-all;
  }
  .van-cell__value {
    flex: unset;
    width: 240px;
    height: 152px;
    margin-left: 40px;
    .right-cover {
      width: 240px;
      height: 152px;
    }
  }
  .label-info-wrap {
    display: flex;
    align-items: center;
    span {
      font-size: 30px;
      line-height: 30px;
      margin-right: 20px;
    }
  }
  .label-cover-wrap {
    padding: 30px 0;
    display: flex;
    // .label-cover-item:not(:last-child) {
    //   padding-right: 12px;
    // }
    .label-cover-item {
      flex: 1;
      height: 146px;
      &:not(:last-child) {
        padding-right: 12px;
      }
    }
  }
}
</style>
